package net.azure.app.model;

import java.util.Collection;
import java.util.List;
import java.util.LinkedList;

/**
 * Created by IntelliJ IDEA.
 * User: Venkatraman Kandaswamy
 * Date: 12-Jun-2008
 * Time: 06:43:01
 */
public class Risk implements IModel{
    Volatility volatility;
    Complexity complexity;
    Completeness completeness;
    Priority priority;
    CalculatedRisk calculatedRisk;

    final int volatilityPosition = 0;
    final int complexityPosition = 1;
    final int completnessPosition = 2;
    final int priorityPosition = 3;
    final int calculatedRiskPosition = 4;

    public Risk(Volatility volatility, Complexity complexity, Completeness completeness, Priority priority, CalculatedRisk calculatedRisk) {
        this.volatility = volatility;
        this.complexity = complexity;
        this.completeness = completeness;
        this.priority = priority;
        this.calculatedRisk = calculatedRisk;
    }

    public Risk(int offset, String ...varArgs){
        volatility = Volatility.convert(varArgs[volatilityPosition+offset]);
        complexity = Complexity.convert(varArgs[complexityPosition+offset]);
        completeness = Completeness.convert(varArgs[completnessPosition+offset]);
        priority = Priority.convert(varArgs[priorityPosition+offset]);
        calculatedRisk = CalculatedRisk.convert(varArgs[calculatedRiskPosition+offset]);
    }

    @Override
    public Object field(int position) {
        switch(position){
            case volatilityPosition : return volatility;
            case complexityPosition : return complexity;
            case completnessPosition : return completeness;
            case priorityPosition : return priority;
            case calculatedRiskPosition : return calculatedRisk;
        }
        return null;
    }

    @Override
    public List<String> header() {
        List<String> header = new LinkedList<String>();
        header.add("Volatility");
        header.add("Complexity");
        header.add("Completeness");
        header.add("Priority");
        header.add("Calculated Risk");
        return header;
    }

    public enum  Volatility {
        High, Medium, Low;
        public static Volatility convert(String strVolatility){
            if("High".equalsIgnoreCase(strVolatility)) return High;
            if("Medium".equalsIgnoreCase(strVolatility))return Medium;
            if("Low".equalsIgnoreCase(strVolatility))return Low;
            return null;
        }
    }
    public enum  Complexity {Complex, Standard, Simple;
        public static Complexity convert(String strComplexity){
            if("Complex".equalsIgnoreCase(strComplexity))return Complex;
            if("Standard".equalsIgnoreCase(strComplexity))return Standard;
            if("Simple".equalsIgnoreCase(strComplexity))return Simple;
            return null;
        }
    }
    public enum  Completeness {Complete, InComlpete, Unknown;

        public static Completeness convert(String strCompleteness) {
            if("complete".equalsIgnoreCase(strCompleteness)) return Complete;
            if("incomplete".equalsIgnoreCase(strCompleteness)) return InComlpete;
            if("unknown".equalsIgnoreCase(strCompleteness)) return Unknown;
            return null;
        }
    }
    public enum  Priority {High, Medium, Low;

        public static Priority convert(String strPriority) {
            if("high".equalsIgnoreCase(strPriority)) return High;
            if("medium".equalsIgnoreCase(strPriority)) return Medium;
            if("low".equalsIgnoreCase(strPriority)) return Low;
            return null;
        }
    }
    public enum  CalculatedRisk {High, Medium, Low;

        public static CalculatedRisk convert(String strCalculatedRisk) {
            if("high".equalsIgnoreCase(strCalculatedRisk)) return High;
            if("medium".equalsIgnoreCase(strCalculatedRisk)) return Medium;
            if("low".equalsIgnoreCase(strCalculatedRisk)) return Low;
            return null;
        }
    }

    public Volatility getVolatility() {
        return volatility;
    }

    public void setVolatility(Volatility volatility) {
        this.volatility = volatility;
    }

    public Complexity getComplexity() {
        return complexity;
    }

    public void setComplexity(Complexity complexity) {
        this.complexity = complexity;
    }

    public Completeness getCompleteness() {
        return completeness;
    }

    public void setCompleteness(Completeness completeness) {
        this.completeness = completeness;
    }

    public Priority getPriority() {
        return priority;
    }

    public void setPriority(Priority priority) {
        this.priority = priority;
    }

    public CalculatedRisk getCalculatedRisk() {
        return calculatedRisk;
    }

    public void setCalculatedRisk(CalculatedRisk calculatedRisk) {
        this.calculatedRisk = calculatedRisk;
    }
}

